package com.spring.graphql.resolver;

import com.coxautodev.graphql.tools.GraphQLMutationResolver;
import com.spring.graphql.models.User;
import com.spring.graphql.repositories.UserRepository;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class Mutation implements GraphQLMutationResolver {

    private UserRepository userRepository;

//    private BCryptPasswordEncoder bCryptPasswordEncoder;

    public Mutation(UserRepository userRepository) {
        this.userRepository = userRepository;
//        this.bCryptPasswordEncoder = new BCryptPasswordEncoder();
    }

    public User newUser(String name, String email, String password, String avatar) {
        User user = new User();
        user.setName(name);
        user.setEmail(email);
        user.setPassword(password);
        user.setAvatar(avatar);
        userRepository.save(user);
        return user;
    }
}
